﻿using Direct.IDAL.Manager.UserCenter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DirectSell.Model.Manager;
using System.Collections;

namespace DirectSell.BLL.Manager.Login
{
    /// <summary>
    /// 会员升级服务层
    /// </summary>
    public class UpgradeAuditService:ManagerService
    {
        #region 日志记录
        /// <summary>
        /// 日志记录文件名
        /// </summary>
        protected override string LogFile
        {
            get
            {
                return "会员升级审核";
            }
        }
        #endregion

        #region 构造函数
        /// <summary>
        /// 升级数据接口
        /// </summary>
        protected IUpgradeAuditRepository _repository { get; set; }
        public UpgradeAuditService(IUpgradeAuditRepository repository)
        {
            this._repository = repository;
        }
        #endregion

        #region 操作入口
        /// <summary>
        /// 操作入口
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="param"></param>
        /// <returns></returns>
        protected override ManagerRespCode Operation<T>(T param)
        {
            var model = param as UpgradeAuditReq;

            if (model == null)
            {
                return ManagerRespCode.传入参数不正确;
            }

            Log(model);

            Hashtable hstable = new Hashtable();

            _repository.UpdateStates(model.Id, model.Type, ref hstable);

            _repository.Uplevel(model.UserCode, model.Level, ref hstable);

            if (!_repository.CommitDapperTranLock(hstable))
            {
                return ManagerRespCode.失败;
            }
            return ManagerRespCode.成功;

        }
        #endregion

    }
}
